﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace FourKill.Engine
{
    public class Coordinates2D : ICoordinates2D, ICloneable
    {
        private static Coordinates2D _origin = new Coordinates2D(0, 0);
        public static Coordinates2D Origin { get { return _origin; } }

        private double _x, _y, _angleFromCamera;
        private PointF _point;

        public Coordinates2D() { }
        public Coordinates2D(double x, double y) { X = x; Y = y; }

        public virtual double X
        {
            get { return _x; }
            set { _x = value; _point.X = Convert.ToSingle(_x); }
        }

        public virtual double Y
        {
            get { return _y; }
            set { _y = value; _point.Y = Convert.ToSingle(_y); }
        }

        public double AngleFromCamera
        {
            get { return _angleFromCamera; }
            set { _angleFromCamera = value; }
        }

        public double AngleFromCameraDegrees
        {
            get { return Utility.Degrees(_angleFromCamera); }
        }

        public PointF PointF
        {
            get { return _point; }
            set { _point = value; _y = _point.Y; _x = _point.X; }
        }

        public virtual object Clone()
        {
            return Coordinates2D.Clone(this);
        }

        public static Coordinates2D Clone(ICoordinates2D c)
        {
            Coordinates2D nc = new Coordinates2D();
            c.CopyInto(nc);
            return nc;
        }

        public void CopyInto(ICoordinates2D c)
        {
            c.X = this.X;
            c.Y = this.Y;
        }

        public static void CopyInto(ICoordinates2D source, ICoordinates2D destination)
        {
            source.CopyInto(destination);
        }
    }
}
